package 力扣_树算法.二叉树;

import java.util.*;

/**亲测Java集合常用实现类,那些不能存储null
 * @author zx
 * @create 2022-04-10 20:19
 */
public class Test {
    public static void main(String[] args) {
        /**
         * ArrayDeque不能存储null
         */
//        Deque queue = new ArrayDeque();
//        queue.offer(null);
//        System.out.println(queue);
        Deque queue1 = new LinkedList();
        queue1.offer(null);
        System.out.println(queue1);
        List list = new LinkedList();
        list.add(null);
        System.out.println(list);
        List list1 = new ArrayList();
        list1.add(null);
        System.out.println(list1);
        Set set = new HashSet();
        set.add(null);
        System.out.println(set);
        Set set1 = new LinkedHashSet();
        set1.add(null);
        System.out.println(set1);
        /**
         * 由于TreeMap的key不能存储null,所以TreeSet不能存储null(详见HashMap源码分析)
         */
//        Set set2 = new TreeSet();
//        set2.add(null);
//        System.out.println(set2);
        Map map = new HashMap();
        map.put(null,null);
        System.out.println(map);
        Map map1 = new LinkedHashMap();
        map1.put(null,null);
        System.out.println(map1);
        Map map2 = new TreeMap();
        map2.put(1,null);
        /**
         * TreeMap的key不能存储null
         */
//        map2.put(null,null);
//        map2.put(null,1);
        System.out.println(map2);
    }
}
